import 'package:ai_desktop_eidtor/common/y_button.dart';
import 'package:ai_desktop_eidtor/common/y_field.dart';
import 'package:ai_desktop_eidtor/common/y_text.dart';
import 'package:ai_desktop_eidtor/routes/app_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'create_logic.dart';
import 'create_state.dart';

class CreatePage extends StatelessWidget {
  const CreatePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final CreateLogic logic = Get.put(CreateLogic());
    final CreateState state = Get.find<CreateLogic>().state;

    return Scaffold(
      appBar: AppBar(title: Text('创建书籍')),
      body: Column(
        children: [
          Container(
            height: 48,
            padding: EdgeInsets.only(left: 16, right: 16),
            margin: EdgeInsets.only(left: 20, right: 20),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(10),
              border: Border.all(width: 0.5, color: Colors.grey),
            ),
            child: YField(
              hintText: '小说名字',
              hintStyle: TextStyle(fontSize: 16, color: Colors.grey),
              textAlign: TextAlign.left,
              controller: logic.titleField,
            ),
          ),
          SizedBox(height: 10),
          Expanded(
            child: Container(
              decoration: BoxDecoration(
                border: Border.all(width: 1, color: Colors.grey),
                borderRadius: BorderRadius.circular(10),
              ),
              margin: EdgeInsets.only(left: 20, right: 20, bottom: 10),
              padding: EdgeInsets.only(left: 16, right: 16, top: 10, bottom: 10),
              child: YField(
                hintText: '小说简介',
                hintStyle: TextStyle(fontSize: 16, color: Colors.grey),
                controller: logic.introField,
                maxLines: 1000,
                textAlign: TextAlign.left,
              ),
            ),
          ),
          Container(
            alignment: Alignment.centerRight,
            margin: EdgeInsets.only(right: 20, bottom: 20),
            child: YButton(
              backgroundColor: Colors.transparent,
              text: '下一步',
              textColor: Colors.blue,
              onPressed: () {
                logic.createBook();
              },
            ),
          ),
        ],
      ),
    );
  }
}
